//package eureka.consumer.redissonlock;
//
//import com.google.common.base.Strings;
//import lombok.extern.slf4j.Slf4j;
//import org.redisson.Redisson;
//import org.redisson.api.RedissonClient;
//import org.redisson.config.Config;
//import org.redisson.config.SingleServerConfig;
//import org.redisson.config.TransportMode;
//import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
//import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
//import org.springframework.boot.context.properties.EnableConfigurationProperties;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.data.redis.core.RedisTemplate;
//
///**
// * @Author RenPu
// * @Date 2021/8/26 11:41
// * @Version 1.0
// * @Description:Redisson分布式依赖配置类
// **/
//
//@Slf4j
//@Configuration
//@ConditionalOnClass(RedisTemplate.class)
//@EnableConfigurationProperties(BaseRedisProperty.class)
//public class BaseRedissonConf {
//
//    @Bean
//    public DistributedLockFactoryBean distributeLockTemplate(BaseRedisProperty redissonProperty) {
//        return new DistributedLockFactoryBean(redissonProperty);
//    }
//
//    /**
//     * 单机模式自动装配
//     *
//     * @return
//     */
//    @Bean
//    RedissonClient redissonSingle(BaseRedisProperty redissonProperty) {
//        String ip = redissonProperty.getHost();
//        Integer port = redissonProperty.getPort();
//
//        BaseRedisProperty.Redisson redisson = redissonProperty.getRedisson();
//        Config config = new Config();
//        if (TransportMode.EPOLL.name().equalsIgnoreCase(redisson.getTransportMode())) {
//            config.setTransportMode(TransportMode.EPOLL);
//        }
//        SingleServerConfig singleServer = config.useSingleServer();
//        singleServer.setAddress("redis://" + ip + ":" + port);
//        singleServer.setTimeout(redisson.getTimeOut());
//        if (!Strings.isNullOrEmpty(redissonProperty.getPassword())) {
//            log.info("redisson 密码不为空，设置密码");
//            singleServer.setPassword(redissonProperty.getPassword());
//        }
//        singleServer.setConnectionPoolSize(redisson.getPoolSize());
//        singleServer.setConnectionMinimumIdleSize(redisson.getMinIdleSize());
//        RedissonClient redissonClient = Redisson.create(config);
//        return redissonClient;
//    }
//
//
//    @Bean("redissonLockTemplate")
//    public RedissonFactoryBean redissonLockTemplate(BaseRedisProperty redissonProperty) {
//        return new RedissonFactoryBean(redissonProperty);
//    }
//}
